package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.system.entity.SysUser;
import com.burst.reptile.modular.zp.entity.ZpReport;
import com.burst.reptile.modular.zp.entity.ZpResources;

public class ZpReportWrapper extends BaseControllerWrapper<ZpReport> {

    public ZpReportWrapper(Page<ZpReport> page) {
        super(page);
    }
    
    public ZpReportWrapper(List<ZpReport> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpReport report) {
    	Long articleId = report.getArticleId();
    	if(ToolUtil.isNotEmpty(articleId)) {
    		ZpResources resources = ConstantFactory.me().getResources(articleId);
    		if(ToolUtil.isNotEmpty(resources)) {
    			report.setTitle(resources.getTitle());
    			Long userId = resources.getUserId();
    			SysUser user = ConstantFactory.me().getUser(userId);
    			if(ToolUtil.isNotEmpty(user)) {
    				report.setUserName(user.getUserName());
    				report.setNickName(user.getNickName());
    			}
    		}
    	}
    }

}
